var http = require("http");
const fs=require("fs")
const path=require("path");


http.createServer((req,res) => {

    var fileName=process.argv[2] 
    var filePath=path.join(__dirname,"/"+fileName);
    var filePath1=path.join(__dirname,"/fileReader1.js");

    if(fs.existsSync(filePath)){
        fs.readFile(filePath,(err,data)=>{  
            if(err){
                console.log(err)
            }else{
                res.end(data.toString("utf-8"));
            }
        })
    }else if(fileName==undefined){
        fs.readFile(filePath1,(err,data)=>{
            if(err){
                console.log(err)
            }else{
                res.end(data.toString("utf-8"))
            }
        })
    }
}).listen(8081);
console.log("server is listening 8081");



